package org.dru.masic.utils {
	import flash.utils.Dictionary;

	public class Logger {
		public static const DEBUG:int = 0;
		public static const INFO:int = 1;
		public static const WARNING:int = 2;
		public static const ERROR:int = 3;
		
		private static var outputs:Dictionary = new Dictionary(true);
		
		public static function log(logLevel:int, logMessage:String):void {
			for (var level:int in outputs) {
				if (logLevel >= level) {
					for each (var output:ILoggerOutput in outputs[level]) {
						output.print(logLevel, logMessage);
					}
				}
			}
		}
		
		public static function registerOutput(output:ILoggerOutput, logLevel:int):void {
			if (!outputs[logLevel]) {
				outputs[logLevel] = new Vector.<ILoggerOutput>();
			}
			
			outputs[logLevel].push(output);
		}

		public function Logger() {
			throw new Error("Do not instantiate");
		}
	}
}